<!--
 * @Descripttion:
 * @version: 1.0.0
 * @Author: htang
 * @Date: 2023-11-09 10:21:36
 * @LastEditors: htang
 * @LastEditTime: 2024-03-02 14:56:05
-->
<template>
  <div class="left-echarts-node">
    <div class="tip">
      <span>门闸控制</span>
    </div>
    <div ref="siteEcharts" id="site-echarts" v-show="false"></div>
    <div class="item flex justify-between items-center">
      <span>门闸: </span>
      <a-select v-model:value="model.entranceCode" :allowClear="false" style="width: 80%">
        <template v-for="(item, index) in entranceList" :key="index">
          <a-select-option :value="item.entranceCode">
            {{ item.entranceName }}
          </a-select-option>
        </template>
      </a-select>
    </div>
    <!-- <div class="item">门闸状态: {{ model.entranceState === 0 ? '关' : '开' }} </div> -->
    <div class="item flex justify-between items-center">
      <a-button @click="handleControl(1)">开门</a-button>
      <a-button type="primary" @click="handleControl(3)">暂停</a-button>
      <a-button type="primary" @click="handleControl(2)">关门</a-button>
    </div>
  </div>
</template>

<script>
import { ref, watch, getCurrentInstance, onMounted, defineComponent, onUnmounted, nextTick } from 'vue';
import { Progress } from 'ant-design-vue';
import '@/assets/js/highcharts/highcharts.js';
import '@/assets/js/highcharts/highcharts-3d.js';
import '@/assets/js/highcharts/modules/exporting.js';
import { entrancePageApi, entranceListApi, entranceDeleteApi, controlApi } from '/@/api/gate/index';
export default defineComponent({
  components: { Progress },
  setup() {
    let { proxy } = getCurrentInstance();
    let model = ref({
      entranceCode: '',
      entranceState: '',
    });
    let entranceList = ref([]);

    let options = ref({});

    let chart;

    function getEntranceList() {
      entranceListApi().then((res) => {
        entranceList.value = res;
        model.value = res[0];
      });
    }

    function handleControl(controlTo) {
      controlApi({ entranceCode: model.value.entranceCode, controlTo }).then((res) => {
        visible.value = false;
        getEntranceList();
      });
    }

    onMounted(() => {
      getEntranceList();
    });

    return {
      model,
      entranceList,
      handleControl,
    };
  },
});
</script>

<style lang="less" scoped>
.left-echarts-node {
  width: 100%;
  height: 100%;
  margin: 0 0 12px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.27) 0%, rgba(0, 0, 0, 0.01) 100%);
  backdrop-filter: blur(100px);
  color: #fff;
  .tip {
    width: 100%;
    height: 44px;
    padding: 0 0 0 43.3px;
    background: url('@/assets/images/img-39.png') no-repeat;
    background-size: 100% 100%;
    line-height: 44px;
    font-size: 16px;
    color: #fff;
  }
  #site-echarts {
    width: 100%;
    height: 180px;
  }
  .legend-list {
    margin: 20.66px 0 0;
    ul {
      display: grid;
      padding: 0 12px;
      margin: 0;
      grid-template-columns: repeat(2, 1fr);
      grid-gap: 30px 40px;
      li {
        width: 100%;
        color: #fff;
        &:first-child {
          .info {
            &::before {
              background: #1ef0d7;
            }
          }
        }
        &:nth-child(2) {
          .info {
            &::before {
              background: #3d67ff;
            }
          }
        }
        &:nth-child(3) {
          .info {
            &::before {
              background: #47bc79;
            }
          }
        }
        .info {
          position: relative;
          &::before {
            content: '';
            position: relative;
            top: -12px;
            display: block;
            width: 7px;
            height: 7px;
            margin: 10px 12px 0 0;
          }
          p {
            padding: 0;
            margin: 0;
            span {
              display: block;
              width: 100%;
              font-family: 'HarmonyOS Sans SC';
              &:first-child {
                font-size: 16px;
              }
              &:last-child {
                font-size: 12px;
              }
            }
          }
        }
        .ant-progress {
        }
      }
    }
  }
  .card {
    width: 80%;
    margin: 20px;
    padding: 10px;
    color: #fff;
    background-color: #679c7a;
    border-radius: 10px;
    padding-left: 20px;

    .title {
      font-size: 25px;
    }
    .value {
      font-size: 40px;
      text-align: right;
      padding-right: 20px;
    }
  }
  .item {
    margin: 10px;
  }
  .item /deep/ .ant-select-selector {
    background: none !important;
  }
  .item /deep/ .ant-select-selection-item {
    color: #fff !important;
  }
  .item /deep/ .ant-select-arrow {
    color: #fff !important;
  }
}
</style>
